package flc.ast.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.Random;

import flc.ast.R;
import flc.ast.bean.MyLineBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class LineAdapter extends StkProviderMultiAdapter<MyLineBean> {

    public LineAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(35));
        addItemProvider(new LineProvider());
    }

    private class LineProvider extends BaseItemProvider<MyLineBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_line;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyLineBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getImg()).into((ImageView) baseViewHolder.getView(R.id.ivLineItemImg));
            baseViewHolder.setText(R.id.tvLineItemName, bean.getName());
            Random random = new Random();
            int num = random.nextInt(200) + 30;
            baseViewHolder.setText(R.id.tvLineItemDelay, getContext().getString(R.string.delay_num, num));
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivLineItemSel, R.drawable.xz);
            } else {
                baseViewHolder.setImageResource(R.id.ivLineItemSel, R.drawable.wxz);
            }
        }
    }
}
